package com.wj.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.wj.dto.RespPageDTO;
import com.wj.pojo.Employee;
import com.wj.pojo.RespBean;
import com.wj.service.IEmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 员工工资账套
 *
 * @Author wj
 * @Date 2022/7/23 18:06
 * @Description: TODO
 * @Version 1.0
 */
@Api(tags = "员工工资账套")
@RestController("/salary/sobcfg")
@RequestMapping("/salary/sobcfg")
public class SalarySobCfgController {

    @Resource
    private IEmployeeService employeeService;

    @ApiOperation("获取所有员工工资账套")
    @GetMapping("/")
    public RespPageDTO getEmployeeWithSalary(@RequestParam(defaultValue = "1") Integer currentPage,
                                             @RequestParam(defaultValue = "10") Integer size){
        return employeeService.getEmployeeWithSalary(currentPage,size);
    }

    @ApiOperation("更新员工工资账套")
    @PutMapping("/")
    public RespBean updateEmployeeWithSalary(Integer eid,Integer sid){
        boolean update = employeeService.update(new UpdateWrapper<Employee>().set("salaryId", sid)
                .eq("id", eid));
        if (update){
            return RespBean.success("更新成功");
        }
        return RespBean.error("更新失败");
    }

}
